package operatori;

import Interpretor.Context;

public class Plus extends Operator {

	public String concatTermeni(String aux1, String aux2) {
		System.out.println("CONCATENEZ PLUS");
		if ((aux1.compareTo("0") == 0) && (aux2.compareTo("0") == 0))
			return "0";

		else if ((aux1.compareTo("0") == 0))
			return aux2;
		else if ((aux2.compareTo("0") == 0))
			return aux1;
		if (aux2.charAt(0) == '-')
			return aux1 + aux2;

		if (aux1.compareTo(aux2) == 0)
			return "2*" + aux2;
		return "(" + aux1 + " + " + aux2 + ")";
	}

	public static String ConcatTermeni(String aux1, String aux2) {
		if ((aux1.compareTo("0") == 0) && (aux2.compareTo("0") == 0))
			return "0";

		else if ((aux1.compareTo("0") == 0))
			return aux2;
		else if ((aux2.compareTo("0") == 0))
			return aux1;
		if (aux2.charAt(0) == '-')
			return aux1 + aux2;

		if (aux1.compareTo(aux2) == 0)
			return "2*" + aux2;
		return "(" + aux1 + " + " + aux2 + ")";
	}
	
	public void interpret(Context cont) {
		cont.actual(this);
	}
/*
 
	public double calcul(double aux1, double aux2) {
		return aux1 + aux2;
	}

	public static double Calcul(double aux1, double aux2) {
		return aux1 + aux2;
	}

	public double calculDerivata() {
		if ((fStang == null) || (fDrept == null))
			System.exit(1);

		return calcul(fStang.calculDerivata(), fDrept.calculDerivata());
	}

	public String derivare() {
		if ((fStang == null) || (fDrept == null))
			System.exit(1);
		return concatTermeni(fStang.derivare(), fDrept.derivare());
	}
*/
}
